<template>
	<view>
		<view class="contentCla">
			<view class="titleCla">
				{{name.titleName}}
			</view>
			<view class="textCla">
				{{name.Content}}
			</view>
			<view class="boxCla">
				<view class="inputCla">
					<u-input maxlength="20" placeholder="请填写职位名称，如“销售专员”" border="bottom" v-model="obj.FullName">
						<view slot="suffix">
							<view class="suffixCla">
								<text class="text1Cla">{{valueNumber}}</text><text class="text2Cla">/20</text>
							</view>
						</view>
					</u-input>
				</view>
				
				<sortSelectionView v-if="!obj.FullName" @sortSelectionEmit="sortSelectionEvent"></sortSelectionView>
				
				<view class="bottomCla">
					<view class="itemCla" v-for="(item,index) in list" :key="index" @click="searchClick(item)">
						<view class="" v-html="$util.hightLight(item.FullName,obj.FullName,'#3476FE')">
							{{item.FullName}}
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import sortSelectionView from "@/pages/component/addindex-page/sortSelection/index.vue"
	export default {
		data() {
			return {
				obj: {
					Id:[],
					FullName:'',
				},
				textNum: 0,
				list:[]
			}
		},
		props: {
			name: {
				type: Object
			},
			nameShow: {
				type: Boolean,
				default: false
			}
		},
		components:{
			sortSelectionView
		},
		watch: {
			nameShow(newVal) {
				if (newVal) {
					this.chuanshuMet()
				}
			},
			textNum(newVal) {
				if (newVal >= 20) {
					this.$util.toast("职位名称不能超过20个字！");
				}
			},
			'obj.FullName'(newVal){
				if(newVal){
					this.thirdList();
					this.hightLight();
				}
			}
		},
		computed: {
			valueNumber() {
				if (this.obj.FullName) {
					this.textNum = this.obj.FullName.replaceAll(" ", "").replace(/(^\s+)|(\s+$)/g, "aa").length;
					return this.textNum;
				}else{
					return 0
				}
			}
		},
		created() {
			this.obj.FullName = this.name.JobName;
		},
		methods: {
			
			hightLight(val, editKeyword,color) {},

			chuanshuMet() {
				this.$emit('toguanjianciData', this.obj)
			},
			
			sortSelectionEvent(val){
				this.obj = val;
			},
			thirdList(){
				this.$http.huirc.category_third({name:this.obj.FullName}).then((res) => {
					if(res.Success){
						this.list = res.Result;
					}
				})
			},
			searchClick(item){
				this.obj.FullName = item.FullName;
				this.obj.Id = item.CategoryIdTree.split(',');
			},
		}
	}
</script>

<style lang="scss" scoped>
	.contentCla {
		background-color: #fff;
		width: 100%;
		min-height: 100vh;

		.titleCla {
			padding: 60rpx 40rpx 10rpx 40rpx;
			font-size: 48rpx;
			font-weight: bold;
			color: #000000;
		}

		.textCla {
			padding: 0 40rpx 10rpx 40rpx;
			font-weight: 500;
			color: #666666;
			font-size: 28rpx;
		}

		.boxCla {
			padding: 20rpx 40rpx 0 40rpx;

			.inputCla {
				.suffixCla {
					display: flex;
					font-size: 26rpx;
					font-weight: 500;

					.text1Cla {
						color: #333333;
					}

					.text2Cla {
						color: #C1C1C1;
					}
				}
			}
			.bottomCla {
				margin-bottom: 20rpx;
			
				.itemCla {
					padding: 20rpx 0;
					border-bottom: 1rpx solid #E2E2E2;
				}
			}

			/deep/.u-input--no-radius {
				padding-bottom: 31rpx !important;
			}

			/deep/.uni-input-placeholder {
				font-size: 34rpx;
				font-weight: 400;
				color: #C1C1C1;
			}

			

		}

	}
</style>